
#ifndef _MEMBER_BTREEWIDGET_H_
#define _MEMBER_BTREEWIDGET_H_

#include <BImage>
#include <BStyle>
#include <BScrollBar>
#include <BScrollArea>
#include <BTreeItem>
#include <BTreeWidget>

#define tree_member(tree)		((member_BTreeWidget*)((BTreeWidget*)tree)->_ptr)

namespace BWE
{
	class member_BTreeWidget : public BObject
	{
	public:
		member_BTreeWidget(BTreeWidget* treeWidget);
		~member_BTreeWidget();
		
		void dirtyItem(BTreeItem* item);
		void freshWidget(BTreeItem* item, bool visual);

		bool freshArea();
		void freshItemRect(const BFont* font, BTreeItem* item, int x, int& y, BSize& areaSize);
		void adjustVisualItem(BTreeItem* item, const BPoint& offset, const BRect& crect);
		bool collectPrevItems(BTreeItem* item, BTreeItem* lastItem, BTreeItemList& collectedItems);
		bool collectNextItems(BTreeItem* item, BTreeItem* lastItem, BTreeItemList& collectedItems);

		void expandAll(BTreeItem* item);
		void shrinkAll(BTreeItem* item);

		void slotCountChanged(BObject* object, const BValue& value);

		BTreeWidget*	boss;
		int				indent;
		int				space;
		BSize			iconSize;
		BSize			arrowSize;
		Align			arrowAlign;
		BSize			itemSize;
		Align			itemAlign;
		Form			itemForm;
		SelectMode		selectMode;
		BIconHolder		expandIcon;
		BIconHolder		shrinkIcon;

		bool			dirty;
		bool			pressed;
		bool			hoveredArrow;
		BTreeItem*		hoveredItem;
		BSize			realArrowSize;

		BArray<BTreeItemHolder>	topItems;
		BList<BTreeItem*>		selectedItems;
		BArray<BTreeItem*>		visualItems;
	};
}
#endif